<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>行政许可审批查询</title>

<%@ include file="/wf/public/meta_wf.jsp"%>
 
<script src="${ctx}/gzcgwsp/resources/js/YwUtil.js" type="text/javascript"></script>
<script src="${ctx}/wf/client/common/js/WfOpinionGrid.js" type="text/javascript"></script>
<script src="${ctx}/wf/client/common/js/WfOpinionPanel.js" type="text/javascript"></script>
<script src="${ctx}/wf/client/common/js/WfSendSuccessWin.js" type="text/javascript"></script>
<script src="${ctx}/wf/client/common/js/WfSendWin.js" type="text/javascript"></script>
<script src="${ctx}/gzcgwsp/state/rqstate/js/WfGrid.js" type="text/javascript"></script>
<script src="${ctx}/wf/client/common/js/WfSendWin.js" type="text/javascript"></script>

<script src="${ctx}/gzcgwsp/iccardManage/js/busGrid.js" type="text/javascript"></script>
<script src="${ctx}/resources/js/aos/ext_ux/BasicComboBox.js" type="text/javascript"></script>

<script type="text/javascript">

Ext.onReady(function(){
	var ywtype=document.getElementById("ywtype").value;
	Ext.QuickTips.init();
	//查询
	var searchForm = new Ext.FormPanel({
			region: 'north',
		title: '行政许可审批查询',
		labelAlign: 'right',
		height: 80,
		frame: true,
		plain: true,
		collapsible:true,
		collapsed:false,
		border: true,
		margins: '1 1 2 1',
		items: [{
			layout: 'column',
			items:[{
				columnWidth: .4,
				layout: 'form',
				items: [{
				xtype: 'basicCombo',
				fieldLabel: '运输公司',
				name: 'qyid',
				hiddenName: 'qyid',
				url: ctx + '/bus-iccard-manage!getCompany.action',
				allowBlank: true,
				anchor: '100%'
			}]
			},{
				columnWidth: .2,
				layout: 'form',
				items: [{
					xtype: 'textfield',
					fieldLabel: '车牌号码',
					emptyText:'车牌号码',
					name: 'cphm',
					editable:false,
					anchor: '100%'
				}]
			},{
				columnWidth: .3,
				layout: 'hbox',
				defaults:{margins:'0 5 0 40'},
				buttonAlign:"right",
				items:[{
					xtype: 'button',
					text: '&nbsp;查询',
					width: 50,
					iconCls: 'icon-find',
					handler: function(){
						this.summaryGrid.store.load();
						//this.searchForm.form.reset();
					},
					scope: this
				},{
					xtype: 'button',
					text: '清空',
					width: 50,
					handler: function(){
						this.searchForm.form.reset();
						this.summaryGrid.store.load();
					},
					scope: this
				}]
			}]
		}
		]
	});
	this.searchForm = searchForm;
	var sm = new Ext.grid.CheckboxSelectionModel();
	var summaryGrid = new Ext.ux.grid.stateGrid({
		
		id: 'state',
		region: 'center',
		margins: '0 1 1 1',
		url: '/bus-iccard-manage!toList.action',
		keyField: 'id',
		defaultSortField: 'create',
		sendCard: true,
		sendAllCard:true,
		readCard:true,
		printCard:true,
		structure: [
		
		  sm,
		
		{
			name:'id',
			header:'id',
			hidden: true
		},{
			name:'pintsts',
			header:'状态',
			width:60
		},{  
			name: 'cphm',  
			header: '车牌号',
			sortable: true,
			width: 120
			
		},{  
			name: 'clbh',  
			header: '标识编号',
			sortable: true,
			width: 120
			
		},{
			name: 'cx',  
			header: '车型',
			width: 100
			
		},{
			name: 'fdjh',  
			header: '发动机号',
			width: 150
		
		},{
			name: 'cjh',  
			header: '车架号',
			width: 150
		
		},{
			name: 'zyzyxqStr',  
			header: '有效日期',
			width: 180
		
		},{
			name: 'writebz',  
			header: '',
			width: 200
		
		}]
	});
	this.summaryGrid = summaryGrid;

	var viewport = new Ext.Viewport({
		layout: 'border',
		items: [searchForm, summaryGrid]
	});
  //summaryGrid.addListener('rowdblclick', openinfo);
	var store = summaryGrid.store;
	store.on('beforeload', function(){
		store.baseParams = {
			groupBy: store.groupField ? store.groupField : null,
			qyid: searchForm.form.findField('qyid').getValue(),//受理编号
			cphm: searchForm.form.findField('cphm').getValue()
		};
	}, this);
	
	refresh = function () {
      this.summaryGrid.store.load();
	}
});
  		//发卡
  function sendCards (){
	var val="";
	var sel = this.summaryGrid.getSelectionModel().getSelections();
	var linenum=summaryGrid.getSelectionModel().lastActive;
	if(linenum>0){
		var prevnum=linenum-1;
		summaryGrid.store.getAt(prevnum).set("writebz" , "");
	     summaryGrid.store.getAt(prevnum).commit();
	}
		if(sel.length == 1){
		  val = sel[0].get('id');
		}else{
			Ext.Msg.alert('系统提示', '只能选择一条记录，请重新选择！');
			return;
		}
	
	 	 Ext.Ajax.request({
			url: 'bus-iccard-manage!sendIccard.action',
			method: 'POST',
			params: {
				id: val
			},
			success: function(response){
			Ext.getBody().unmask();
			var flag = response.responseText;
				if(flag=="true"){
				    sel[0].set('pintsts',"√");
              	  	sel[0].set('writebz',"<font color='read'>请放下一张卡</font>");
				}else{
					//标识状态
					sel[0].set('pintsts',"×");
              	  	sel[0].set('writebz',"<font color='read'>请重放卡</font>");
              	  	sel[0].commit();
				}
			},
			failure: function(){
				Ext.Msg.alert('系统提示', '读取ic卡失败!');
			}
		});
	
}
//打卡
function printCard(){
	var sel = this.summaryGrid.getSelectionModel().getSelections();
		
 	 var busId="";
 	 if(sel.length == 1){
		  busId = sel[0].get('id');
		}
	 var url="bus-iccard-manage!printViewCard.action?id="+busId;
    YwUtil.openWin({url: url, w: 600, h: 300});
}

//读卡
function  readCard(){
  var action="bus-iccard-manage!readCard.action";
  YwUtil.openWin({url: action, w: 700, h: 400});
}


</script>
</head>

<body>
<div id="toolbar"></div>


<input type="hidden" id="ywtype" name="ywtype" value=""/>
</body>
</html>